package com.marketapp.domain;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;

@NamedQueries({
		@NamedQuery(name = "getAllEquityByName", query = "from Equity eq where UPPER(eq.equityName) LIKE :equityName"),
		@NamedQuery(name = "getAllEquityByIdentifier", query = "from Equity eq where UPPER(eq.equityBSE) = :equityBSE " +
				"and UPPER(eq.equityNSE) = :equityNSE and UPPER(eq.equityISIN) = :equityISIN") })
@Entity
@Table(name = "EQUITY_MASTER")
public class Equity {

	private int equityId;
	private String equityName;
	private String equityBSE;
	private String equityNSE;
	private String equityISIN;
	private Sector equitySector;

	public Equity() {

	}

	public Equity(int equityId, String equityName, String equityBSE,
			String equityNSE, String equityISIN, Sector equitySector) {
		this.equityId = equityId;
		this.equityName = equityName;
		this.equityBSE = equityBSE;
		this.equityNSE = equityNSE;
		this.equityISIN = equityISIN;
		this.equitySector = equitySector;
	}

	@Id
	@GeneratedValue(strategy = GenerationType.IDENTITY)
	@Column(name = "EQUITY_ID", nullable = true)
	public int getEquityId() {
		return equityId;
	}

	public void setEquityId(int equityId) {
		this.equityId = equityId;
	}

	@Column(name = "EQUITY_NAME")
	public String getEquityName() {
		return equityName;
	}

	public void setEquityName(String equityName) {
		this.equityName = equityName;
	}

	@Column(name = "EQUITY_BSE_CD")
	public String getEquityBSE() {
		return equityBSE;
	}

	public void setEquityBSE(String equityBSE) {
		this.equityBSE = equityBSE;
	}

	@Column(name = "EQUITY_NSE_CD")
	public String getEquityNSE() {
		return equityNSE;
	}

	public void setEquityNSE(String equityNSE) {
		this.equityNSE = equityNSE;
	}

	@Column(name = "EQUITY_ISIN")
	public String getEquityISIN() {
		return equityISIN;
	}

	public void setEquityISIN(String equityISIN) {
		this.equityISIN = equityISIN;
	}

	@ManyToOne(cascade = CascadeType.ALL)
	@JoinColumn(name = "SECTOR_ID")
	public Sector getEquitySector() {
		return equitySector;
	}

	public void setEquitySector(Sector equitySector) {
		this.equitySector = equitySector;
	}

}
